package com.jettech.oa.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.jettech.oa.dao.UserDAO;
import com.jettech.oa.domain.Resource;
import com.jettech.oa.domain.User;
import com.jettech.oa.service.UserService;

/**
 * 用户服务接口实现类���
 * @author haichenwang
 *
 */
@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDAO userDAO;
	@Transactional(readOnly = true)
	public User getUser(Long id) {
		return userDAO.findById(id);
	}

	@Transactional(propagation=Propagation.REQUIRED)
	public void saveOrUpdateUser(User user) {
		userDAO.makePersistent(user);
	}
	
	@Transactional(readOnly = true)
	public boolean validateUserLoginNameExist(String loginName) {
		return userDAO.validateUserLoginNameExist(loginName);
	}

	@Transactional(readOnly=true)
	public User getUser(String loginName) {
		return userDAO.getUser(loginName);
	}

	@Transactional(readOnly = true)
	public List<User> findAllUser() {
		return userDAO.findAll();
	}

	@Transactional(readOnly = true)
	public List<Resource> findUserOperationResourceList(String loginName) {
		return userDAO.findUserOperationResourceList(loginName);
	}

	public List<Resource> findUserOperationResourceList(Long roleId) {
		return userDAO.findUserOperationResourceList(roleId);
	}

	public List<String> findUserLoginNameOfRole(String roleName) {
		return null;
	}

	public List<String> findUserLoginNameOfMyDepartment(Long documentId) {
		return userDAO.findUserLoginNameOfMyDepartment(documentId);
	}

}
